<?php
require_once('../connection.php');
if(isset($_GET['id'])) {
  $sql = 'SELECT * FROM `user` WHERE id=?';
  $sth = $db->prepare($sql);
  $sth->execute(array($_GET['id']));
  $res = $sth->fetch();
  echo json_encode($res);
} else if($_GET['uid']) {
  $sql = 'SELECT * FROM `user` WHERE id=?';
  $sth = $db->prepare($sql);
  $sth->execute(array($_GET['uid']));
  $res = $sth->fetch();
  echo json_encode($res);
} else {
  $sql = 'SELECT * FROM `user`';
  $sth = $db->prepare($sql);
  $sth->execute();
  $res = $sth->fetchAll();
  echo json_encode($res);
}
?>